package com.yingside.calendar;

import java.util.Scanner;

public class Test {
    public static void main(String [] args) {
       /* Scanner input = new Scanner(System.in);
        System.out.println("请输入年份:");
        int year = input.nextInt();
        System.out.println("请输入月份:");
        int month = input.nextInt();*/

       //比如这是某一年的一月

        System.out.println("日\t一\t二\t三\t四\t五\t六");
        for (int i=1; i<=31; i++){
            System.out.print(i + "\t");
            if(i % 7 == 0){
                System.out.println();
            }
        }

        System.out.println("\n=============\n");
        //比如接下去要打印2月的日历
        //先求出前面需要空几位
        int temp2 = 31 % 7;

        System.out.println("日\t一\t二\t三\t四\t五\t六");
        for (int i=1; i<=temp2; i++){
            System.out.print("\t");
        }

        for (int i=1; i<=28; i++){
            System.out.print(i + "\t");
            if((31 + i) % 7 == 0){
                System.out.println();
            }
        }

        System.out.println("\n=============\n");
        //比如求某一年三月的日历
        int temp3 = (31+28) % 7;

        System.out.println("日\t一\t二\t三\t四\t五\t六");
        for (int i=1; i<=temp3; i++){
            System.out.print("\t");
        }

        for (int i=1; i<=31; i++){
            System.out.print(i + "\t");
            if((31 + 28 + i) % 7 == 0){
                System.out.println();
            }
        }

        System.out.println("\n=============\n");
        //比如求某一年三月的日历
        int temp4 = (31+28 + 31) % 7;

        System.out.println("日\t一\t二\t三\t四\t五\t六");
        for (int i=1; i<=temp4; i++){
            System.out.print("\t");
        }

        for (int i=1; i<=30; i++){
            System.out.print(i + "\t");
            if((31 + 28 + 31 + i) % 7 == 0){
                System.out.println();
            }
        }

        System.out.println("\n=============\n");
        //接下来直接求10月的日历
        int temp10 = (31+28+31+30+31+30+31+31+30) % 7;

        System.out.println("日\t一\t二\t三\t四\t五\t六");
        for (int i=1; i<=temp10; i++){
            System.out.print("\t");
        }

        for (int i=1; i<=31; i++){
            System.out.print(i + "\t");
            if((31+28+31+30+31+30+31+31+30+i) % 7 == 0){
                System.out.println();
            }
        }


        System.out.println("\n=============\n");
        //接下来，下一年5月的日历 上一年365天+1-4月的总天数
        int totalDays = 365 + 31+28+31+30;
        int temp5 = totalDays % 7;

        System.out.println("日\t一\t二\t三\t四\t五\t六");
        for (int i=1; i<=temp5; i++){
            System.out.print("\t");
        }

        for (int i=1; i<=31; i++){
            System.out.print(i + "\t");
            if((totalDays+i) % 7 == 0){
                System.out.println();
            }
        }
    }
}
